#include<reg51.h>  			//???
unsigned char code discode1[]=                                  			{0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};	
                             	//?????0~9????, ????
unsigned char code discode2[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};	
                            	//?????0~9????,?????
unsigned char timer=0;		//timer??????
unsigned char second;        	//second???
unsigned char key=0;		//key??????

main()				//???
{
	 TMOD=0x01;			//???T0??1??
	 ET0=1;                   	//?????T0??
EA=1;                    		//?????
second=0;                		//????
P0=discode1[second/10];   		//????0
P2=discode2[second%10];   		//??0.1s?0
while(1)				 //??
{	
	if((P3&0x80)==0x00)		//???????
	{	 
		key++;			//?????1
		switch(key)		//???????????
		{
			case 1:		//????????????
			TH0=0xee; 	//?TH0??????8?
	TL0=0x00;	   	//?TL0??????8?,??5ms
	TR0=1;         		//?????T0
	break;
	case 2:        		//????????
	TR0=0;         		//?????T0
	break;
	case 3:        			//??3????0
	key=0;         			//?????
	second=0;      			//???0
	P0=discode1[second/10];   	//????0   				P2=discode2[second%10];  	//??0.1s?0
	break;
}
while((P3&0x80)==0x00);     		//????????????
}
	}
}
void int_T0() interrupt 1  using 0 		//???T0????
{						
	TR0=0;		 	//????,??????(???????)
	TH0=0xee;	  	//?TH0??????8?
	TL0=0x00;	   	//?TL0??????8?,??5ms
	timer++;   	   	//??????
	if (timer==20)	   	//??20?,???20*5ms=100ms=0.1s
	{
		timer=0;    			//?????0
		second++;   			//?0.1s
		P0=discode1[second/10]; 	//????,??????		P2=discode2[second%10]; 	//????,????0.1s?	 }
if(second==99) 		 //????9.9s?
{
	TR0=0;			//????
	second=0;		//???0		
	key=2;	  		//????2,????????,					//key++,?key=3,???0??	
}                           
else				//????9.9s?
{
	TR0=1;			//?????????
}
}
}